/*
 * testLexParse.cpp
 *
 *   Created on: 2011-10-2
 *       Author: 左白
 *  Description: 测试词法分析
 */

#include <iostream>
#include <cstdio>
#include "parse.h"

using namespace std;
using namespace zach;

int main()
{
	LexText text;
	// 测试正确的词法文本
	try {
		text = parseLex( "test/testLexParse.zach" );
	}
	catch ( const OutOfDomain& e ) {
		// 此处不应该有错误
		cout << e.message() << endl;
	}

	for ( int i = 0; i != text.text.size(); ++i ) {
		cout << text.text[i].type << ' ' << toString( text.text[i].string ) << endl;
	}

	// 测试错误的词法文本
	try {
		text = parseLex( "test/testLexParseError.zach" );
	}
	catch ( const OutOfDomain& e ) {
		cout << e.message() << endl;
	}
	return 0;
}
